package com.kmproject.haifu.app.utils;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.xw.repo.XEditText;

public class StringUtils {
    public StringUtils() {
        throw new AssertionError("你不能初始化工具类");
    }

    /**
     * 手机号处理
     *
     * @param phone
     * @return
     */
    public static String hindPhone(String phone) {
        if (TextUtils.isEmpty(phone) || phone.length() < 4) {
            return phone;
        }
        return phone.substring(0, 3) + "*********" + phone.substring(phone.length() - 3, phone.length());
    }

    /**
     * 判断textView或者EditText 是否为空
     *
     * @param view
     * @return
     */
    public static boolean ViewisEnpty(View view) {
        if (view == null)
            return true;
        if (view instanceof TextView) {
            if (((TextView) view).getText().toString().trim().length() < 1) {
                return true;
            }
            return false;
        }

        if (view instanceof EditText) {
            if (((EditText) view).getText().toString().trim().length() < 1) {
                return true;
            }
            return false;
        }
        if (view instanceof XEditText) {
            if (((XEditText) view).getText().toString().trim().length() < 1) {
                return true;
            }
            return false;
        }
        return false;
    }
}
